package com.dhecp.project.quartz.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.dhecp.common.core.controller.BaseController;
import com.dhecp.common.core.domain.AjaxResult;
import com.dhecp.project.quartz.service.SysJobCommonService;

/**
 * 定时任务通用调用方法（调用目标字符串） 控制层
 * @author DH-Xxj
 * @version 2020年11月25日
 */
@Controller
@RequestMapping("/quartz/jobcommon")
public class SysJobCommonController extends BaseController{

    @Autowired
    private SysJobCommonService jobCommonService;

    /**
	 * 数据库可执行定时任务通用调用方法
	 * @param callingMethod 可执行SQL语句字符串
     * @return
     * @author DH-Xxj
     */
    @PostMapping("/callingmethod")
    @ResponseBody
    public AjaxResult jobCommonCallingMethod(String callingMethod) {
    	AjaxResult ajaxResult = new AjaxResult();   
        try {
            ajaxResult= jobCommonService.jobCommonCallingMethod(callingMethod);
        }catch (Exception e) {
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }

    /**
	 * 数据库可执行定时任务通用调用方法
	 * @param callingMethod 可执行SQL语句字符串
     * @return
     * @author DH-Xxj
     */
    @PostMapping("/createProductAssemble")
    @ResponseBody
    public AjaxResult createProductAssemble() {
    	AjaxResult ajaxResult = new AjaxResult();
        try {
            ajaxResult= jobCommonService.createProductAssemble();
        }catch (Exception e) {
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }

    /**
	 * 数据库可执行定时任务通用调用方法
	 * @param callingMethod 可执行SQL语句字符串
     * @return
     * @author DH-Xxj
     */
    @PostMapping("/updateAssemblyMaintain")
    @ResponseBody
    public AjaxResult updateAssemblyMaintain() {
    	AjaxResult ajaxResult = new AjaxResult();
        try {
            ajaxResult= jobCommonService.updateAssemblyMaintain();
        }catch (Exception e) {
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }

    /**
	 * 数据库可执行定时任务通用调用方法
	 * @param callingMethod 可执行SQL语句字符串
     * @return
     * @author DH-Xxj
     */
    @PostMapping("/updateOperateCompanyRatio")
    @ResponseBody
    public AjaxResult updateOperateCompanyRatio() {
    	AjaxResult ajaxResult = new AjaxResult();
        try {
            ajaxResult= jobCommonService.updateOperateCompanyRatio();
        }catch (Exception e) {
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }

    /**
     *@Description: 定时删除任务
     *@Param: []
     *@return: com.dhecp.common.core.domain.AjaxResult
     *@Author: fxz
     *@date: 2023-02-23 14:36
     */
    @PostMapping("/deleteTask")
    @ResponseBody
    public AjaxResult deleteTask() {
    	AjaxResult ajaxResult = new AjaxResult();
        try {
            ajaxResult= jobCommonService.deleteTask();
        }catch (Exception e) {
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }

    /**
     *@Description: 定时海外仓入库任务
     *@Param: []
     *@return: com.dhecp.common.core.domain.AjaxResult
     *@Author: fxz
     *@date: 2023-12-18 14:36
     */
    @PostMapping("/stockInJob")
    @ResponseBody
    public AjaxResult stockInJob() {
        AjaxResult ajaxResult = new AjaxResult();
        try {
            ajaxResult= jobCommonService.stockInJob();
        }catch (Exception e) {
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }


    /**
     *@Description: 定时海外仓库存历史
     *@Param: []
     *@return: com.dhecp.common.core.domain.AjaxResult
     *@Author: fxz
     *@date: 2023-12-18 14:36
     */
    @PostMapping("/addHwStorageHistory")
    @ResponseBody
    public AjaxResult addHwStorageHistory() {
        AjaxResult ajaxResult = new AjaxResult();
        try {
            ajaxResult= jobCommonService.addHwStorageHistory();
        }catch (Exception e) {
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }
}
